﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IntroduceCompany.Util;
using IntroduceCompany.Singleton;

namespace IntroduceCompany.Controllers
{
    [HandleError]
    public class CompanyMemberController : BaseController
    {
        //
        // GET: /CompanyMember/

        #region Backend

        [Authorize(Roles = ConstantClass.autMember)]
        public ActionResult CompanyMemberList_Backend()
        {
            //Check Cookie Language
            string languageID = ConstantClass.markViewAllLanguage;
            if (Request.Cookies[ConstantClass.cooLanguage] != null && Request.Cookies[ConstantClass.cooLanguage].Value != "")
            {
                languageID = Request.Cookies[ConstantClass.cooLanguage].Value;
            }

            ViewData["LaguageList"] = new SelectList(DataSingleton.GetLanguageModels().GetLanguageList().ToList(), "LanguageID", "LanguageName", languageID);


            return View("/Views/Backend/CompanyMember/CompanyMemberList.aspx", DataSingleton.GetCompanyMemberModels().GetCompanyMemberList(languageID));

        }


        [Authorize(Roles = ConstantClass.autMember)]
        public ActionResult CompanyMemberCreate()
        {


            ViewData["Gender"] = new SelectList(DataSingleton.GetGenderModels().GetGenderList("vi"), "GenderID", "GenderName");
            ViewData["LaguageList"] = new SelectList(DataSingleton.GetLanguageModels().GetLanguageList().ToList(), "LanguageID", "LanguageName", ConstantClass.mainLanguageID);

            return View("/Views/Backend/CompanyMember/CompanyMemberCreate.aspx");
        }


        [Authorize(Roles = ConstantClass.autMember)]
        public ActionResult CompanyMemberEdit(int memberID, String memberLanguageID)
        {

            //Check Cookie Language
            string languageID = ConstantClass.markViewAllLanguage;
            if (Request.Cookies[ConstantClass.cooLanguage] != null && Request.Cookies[ConstantClass.cooLanguage].Value != "")
            {
                languageID = Request.Cookies[ConstantClass.cooLanguage].Value;
            }


            ViewData["Gender"] = new SelectList(DataSingleton.GetGenderModels().GetGenderList("vi"), "GenderID", "GenderName");
            ViewData["LaguageList"] = new SelectList(DataSingleton.GetLanguageModels().GetLanguageList().ToList(), "LanguageID", "LanguageName", memberLanguageID);

            return View("/Views/Backend/CompanyMember/CompanyMemberEdit.aspx", DataSingleton.GetCompanyMemberModels().GetOneMember(memberID, memberLanguageID));

        }



        #endregion




        #region Frontend



        #endregion

    }
}
